// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import ElementUI from 'element-ui'; // 全局引入
// import { Button } from 'element-ui'; // 按需引入
import 'element-ui/lib/theme-chalk/index.css';
import VueCodemirror from 'vue-codemirror'
import 'codemirror/lib/codemirror.css'
import 'codemirror/addon/lint/lint.css';
import 'code-mirror-themes/themes/putty.css';
import 'script-loader!jsonlint';
import 'codemirror/mode/javascript/javascript';
import 'codemirror/addon/lint/lint';
import 'codemirror/addon/lint/json-lint';


import mavonEditor from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'


import App from './App'
import router from './router'
import store from './store/index'
// import {https} from './http-utils/request';
// window._https = https;
//定义全局变量
// import {https} from './http-utils/http'
// Vue.prototype.$https = https;

import 'babel-polyfill';
// 通信
import "./utils/postMessageUtil"
import {eventBus} from "./eventBus/bus";
import {formatDate} from './utils/dateFormat';


Vue.config.productionTip = false // 阻止 vue 在启动时生成生产提示。

Vue.use(ElementUI); // 全局引入
// Vue.use(Button); // 按需引入
Vue.use(VueCodemirror);
Vue.use(mavonEditor);

// 全局过滤器
Vue.filter('formatDate', function (value) {
  return formatDate(value, "yyyy-MM-dd hh:mm:ss")
  // return formatDate(value, "yyyy-MM-dd")
});
// debugger
/* eslint-disable no-new */
// let status = false;

if (window.parent == window && window.opener == null) {
  createVue();
} else if (window.parent != window && window.opener == null) {
  eventBus.bus.$on(eventBus.CHANGE_TABS, createVue)
} else {
  eventBus.bus.$on(eventBus.CHANGE_OPENER, createVue);
  // if (!status) {
  //   createVue();
  //   status = false;
  // }
}

function createVue() {
  new Vue({
    el: '#app',
    router,
    components: {App},
    template: '<App/>',
    store
  });

  // status = true;
}


